
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="utf-8">
  <title>编辑页面</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" th:href="@{/layui/css/layui.css}" media="all">
  <link rel="stylesheet" th:href="@{/style/custom.css}" media="all">
</head>
<body>

  <div class="layui-form" lay-filter="app-info-form-edit" id="app-info-form-edit" style="padding: 20px 30px 0 0;">
    <input type="hidden" id="id" name="id" th:value="${formData.id}"/>
    <div class="layui-form-item">
      <div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
        <label class="layui-form-label">所属服务</label>
        <div class="layui-input-block">
          <input type="text" name="serviceName" th:value="${formData.serviceName}" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input" lay-affix="clear">
        </div>
      </div>
      <div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
        <label class="layui-form-label">任务名称</label>
        <div class="layui-input-block">
          <input type="text" name="jobName" th:value="${formData.jobName}" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input" lay-affix="clear">
        </div>
      </div>
    </div>
    <div class="layui-form-item">
      <div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
        <label class="layui-form-label">任务分组</label>
        <div class="layui-input-block">
          <input type="radio" name="jobGroup" value="Y" title="默认" th:checked="${ formData.jobGroup == null || formData.jobGroup == 'DEFAULT'} ? true">
          <input type="radio" name="jobGroup" value="N" title="批量" th:checked="${ formData.jobGroup == 'BATCH'} ? true">
        </div>
      </div>
      <div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
        <label class="layui-form-label">执行目标</label>
        <div class="layui-input-block">
          <input type="text" name="jobTarget" th:value="${formData.jobTarget}" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input" lay-affix="clear">
        </div>
      </div>
    </div>
    <div class="layui-form-item">
      <div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
        <label class="layui-form-label">任务描述</label>
        <div class="layui-input-block">
          <input type="text" name="jobDesc" th:value="${formData.jobDesc}" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input" lay-affix="clear">
        </div>
      </div>
      <div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
        <label class="layui-form-label">Cron表达式</label>
        <div class="layui-input-block">
          <input type="text" name="jobCron" th:value="${formData.jobCron}" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input" lay-affix="clear">
        </div>
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">任务参数</label>
      <div class="layui-input-block">
        <textarea name="jobParam" placeholder="请输入内容" th:text="${formData.jobParam}" class="layui-textarea"></textarea>
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">状态</label>
      <div class="layui-input-block">
        <input type="radio" name="status" value="Y" title="启用" th:checked="${ formData.status == null || formData.status == 'Y'} ? true">
        <input type="radio" name="status" value="N" title="禁用" th:checked="${ formData.status == 'N'} ? true">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">备注</label>
      <div class="layui-input-block">
        <textarea name="remark" placeholder="请输入内容" th:text="${ formData.remark }" class="layui-textarea"></textarea>
      </div>
    </div>
    <div class="layui-form-item layui-hide">
      <input type="button" lay-submit lay-filter="LAY-app-info-front-submit" id="LAY-app-info-front-submit" value="确认">
    </div>
  </div>

  <script th:src="@{/layui/layui.js}"></script>
  <script>
    layui.config({
      base: '/'
    }).use(['index'], function () {
      const $ = layui.$
        ,admin = layui.admin
        ,form = layui.form
        ,table = layui.table
        ,layer = layui.layer
        ,dropdown = layui.dropdown
        ,util = layui.util
        ,flying = layui.flying;

      // 普通事件
      util.on('lay-on', {
        // 获取密钥
        "get-secret": function(othis){
          //提交 Ajax 成功后，静态更新表格中的数据
          admin.req({
            url: '/esb/application/getSecret' ,
            type: 'post',
            success: function (res) {
              //执行成功
              layer.msg(res.msg, {icon: 1});
              form.val('app-info-form-edit', {
                "appSecret" : res.data
              });
            }
          });
        },
        // 获取平台公私钥对
        "get-pair": function(othis){
          let data = form.val("app-info-form-edit");
          //提交 Ajax 成功后，静态更新表格中的数据
          admin.req({
            url: '/esb/application/getSecret?type=' + data.keyAe + '&appId=' + data.appId,
            type: 'post',
            success: function (res) {
              //执行成功
              layer.msg(res.msg, {icon: 1});
              form.val('app-info-form-edit', {
                "pubKey" : res.data.pub,
                "priKey" : res.data.pri,
              });
            }
          });
        },
        // 获取平台密钥
        "get-key": function(othis){
          let data = form.val("app-info-form-edit");
          //提交 Ajax 成功后，静态更新表格中的数据
          admin.req({
            url: '/esb/application/getSecret?type=' + data.keySe + '&appId=' + data.appId,
            type: 'post',
            success: function (res) {
              //执行成功
              layer.msg(res.msg, {icon: 1});
              form.val('app-info-form-edit', {
                "secretKey" : res.data
              });
            }
          });
        }
      });

    });
  </script>
</body>
</html>